package org.example.jd.controller;

import com.sun.org.apache.xpath.internal.operations.Bool;
import org.example.jd.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @Classname ContentController
 * @Description TODO
 * @Date 2020/5/20 16:45
 * @Created by 苟晓健
 */
@RestController
public class ContentController {

    @Autowired
    private ContentService service;


    @GetMapping("parse/{keywords}")
    public Boolean paese(@PathVariable("keywords") String keywords) throws Exception {
        return service.parseContent(keywords);
    }


    @GetMapping("search/{keyword}/{pageNo}/{pageSize}")
    public List<Map<String, Object>> search(@PathVariable("keyword") String keyword, @PathVariable("pageNo") int pageNo,
                                            @PathVariable("pageSize") int pageSize) throws IOException {

        List<Map<String, Object>> list = service.searchPage(keyword, pageNo, pageSize);
        return list;
    }


     @GetMapping("searchHight/{keyword}/{pageNo}/{pageSize}")
    public List<Map<String, Object>> searchHight(@PathVariable("keyword") String keyword,
                                                 @PathVariable("pageNo") int pageNo, @PathVariable("pageSize") int pageSize)
             throws IOException {
        List<Map<String, Object>> list = service.searchHightPage(keyword, pageNo, pageSize);
        return list;
    }


}
